#if !defined(ximera_stacktrace_hpp)
#define ximera_stacktrace_hpp

// -----------------------------------------------------------

#include <ximera/types.hpp>
#include <ximera/common/sharedptr.hpp>
#include <deque>

namespace ximera
{
    struct StackItem
    {
        String name;
        String file;
        int line;

        StackItem()
            : line(0) {}
    };

    namespace detail
    {
        class StackTraceImpl;
    }
    
    class StackTrace
    {
    public:
        typedef std::deque<StackItem> ItemContainer;
        typedef ItemContainer::const_iterator ItemIterator;

    public:
        StackTrace();

        void popFront() { _items.pop_front(); }

        ItemIterator begin() const { return _items.begin(); }
        ItemIterator end() const { return _items.end(); }

    private:
        ItemContainer _items;
        SharedPtr<detail::StackTraceImpl> _impl;
    };

    inline std::wostream& operator<<(std::wostream& os, StackTrace const& stack)
    {
        for (StackTrace::ItemIterator it = stack.begin(), end = stack.end(); it != end; ++it)
            os << it->file << "(" << it->line << ") : " << it->name << std::endl;

        return os;
    }
}

#endif